<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="java.util.ArrayList,
                com.scalar.chiptrack.utils.ConfigManager" %>


<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/jsp/operations/sort_bin_data_entry.jsp"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>


<%	String waferId  =(String)request.getAttribute("waferId");
	String waferNo  =(String)request.getAttribute("waferNo");
	String dieWafer =(String)request.getAttribute("dieWafer");

%>



<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script>


function next()
{
	document.sortBinDataEntry.action='<%=chipTracContext%>/binDataEntrySave.do';
	document.sortBinDataEntry.submit();
		
}

function checkQuantity(){

var pa				 =	document.getElementById("message");
var absoluteDieWafer = document.sortBinDataEntry.absDieWafer.value;
var totalBins        = document.sortBinDataEntry.noOfBins.value;
totalQuantity		 = 0;
var err				 = document.sortBinDataEntry.error.value	

if(err=='true')
pa.innerHTML = "";

for(var i=0;i<parseInt(totalBins);i++){
binQuantity=document.sortBinDataEntry.binQuantity[i].value
if(binQuantity=='')
binQuantity = '0';

if (!isInteger(binQuantity)){
pa.innerHTML = "Please enter valid Quantity ,Quantity must be number";
document.sortBinDataEntry.error.value='true';
document.sortBinDataEntry.binQuantity[i].value='';
document.sortBinDataEntry.binQuantity[i].select();
document.sortBinDataEntry.binQuantity[i].focus();
return;
}
totalQuantity = parseInt(totalQuantity)+parseInt(binQuantity);	
if(totalQuantity>parseInt(absoluteDieWafer)){
pa.innerHTML = "Total quantites should not be greate than Die Wafer";
document.sortBinDataEntry.error.value='true';
document.sortBinDataEntry.binQuantity[i].value='';
document.sortBinDataEntry.binQuantity[i].select();
document.sortBinDataEntry.binQuantity[i].focus();
return;

}
}
document.sortBinDataEntry.dieWafer.value=parseInt(absoluteDieWafer)- parseInt(totalQuantity);
}
</script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<html:form name="sortBinDataEntry" type="com.scalar.chiptrack.operations.dataentry.forms.BinDataEntryForm" action="/binDataEntrySave" >

<input type="hidden" name="waferNo" value="<%=waferNo%>">

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%@ include file="/jsp/operations/dataentryMenu.jsp" %>

	</TD>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="90%" align=right>

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<table border="0"  width="100%" >
  <tr bgcolor="#31639C">
   <td bgcolor="#FFFFFF" >
  <p align="center"><span class="NArialW">Bin Information</span></p>
  <center>
  <strong><font face="Verdana" size="-5" align="center" color="#ff0000" id="message"></font>
  </center>
  <p align="right"><span class="NArialL">Die/Wafer</span>
 <input type="text" name="dieWafer" value="<%=dieWafer%>" disabled=true  size="5" >
 </p>	
	
 <input type="hidden" name="absDieWafer" value="<%=dieWafer%>"  >
 <input type="hidden" name="error" value=""  >	


  <table border="0" width="100%" >
    <tr>
      <td width="10%"  bgcolor="#993333" height="27" align="center">
	  <font class="NArialL"><font color="#FFFFFF">Wafer ID</td>

	<% int i=1; %>
	<logic:iterate id="binQuantityList" name="binQuantityList">
	<logic:notEqual name="binQuantityList" value="null">	

      <td width="5%"  bgcolor="#993333" height="27" align="center">
	  <font class="NArialL"><font color="#FFFFFF">Bin<%=i%></td>
   	<% i=i+1;%>
  </logic:notEqual>
  </logic:iterate> 
   </tr>
    <tr>
	 <td width="10%" bgcolor="#DEE1E2" height="27" align="center">
	 <input type="text" name="waferid" size="6" value="<%=waferId%>" class="txfield"></td>
   <logic:iterate id="binList" name="binList">
   <logic:notEqual name="binList" value="null">	
   <td width="10%" bgcolor="#DEE1E2" height="27" align="center">
   <html:text  name="binList" property="binQuantity" size="6" styleClass="txfield" onchange="checkQuantity()" /></td>
  </logic:notEqual>
  </logic:iterate> 
   </tr>
   </table>
  <input type="hidden" name="noOfBins" value=<%=i-1%>>	
  <center><a href="javascript:next()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a></center>

<!-- till here -->
</TD>
</TR>
 
</table>
</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>